home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / SINFT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  916b  |  39 lines

  1. PROCEDURE sinft(VAR y: glyarray; n: integer);
  2. (* Programs using routine SINFT must define the type
  3. TYPE
  4.    glyarray = ARRAY [1..n] OF real;
  5. where n is the dimension of the input data. *)
  6. VAR
  7.    jj,j,m,n2: integer;
  8.    sum,y1,y2: real;
  9.    theta,wi,wr,wpi,wpr,wtemp: double;
  10. BEGIN
  11.    theta := 3.14159265358979/n;
  12.    wr := 1.0;
  13.    wi := 0.0;
  14.    wpr := -2.0*sqr(sin(0.5*theta));
  15.    wpi := sin(theta);
  16.    y[1] := 0.0;
  17.    m := n DIV 2;
  18.    n2 := n+2;
  19.    FOR j := 2 TO (m+1) DO BEGIN
  20.       wtemp := wr;
  21.       wr := wr*wpr-wi*wpi+wr;
  22.       wi := wi*wpr+wtemp*wpi+wi;
  23.       y1 := sngl(wi)*(y[j]+y[n2-j]);
  24.       y2 := 0.5*(y[j]-y[n2-j]);
  25.       y[j] := y1+y2;
  26.       y[n2-j] := y1-y2
  27.    END;
  28.    realft(y,m,+1);
  29.    sum := 0.0;
  30.    y[1] := 0.5*y[1];
  31.    y[2] := 0.0;
  32.    FOR jj := 0 TO (m-1) DO BEGIN
  33.       j := 2*jj+1;
  34.       sum := sum+y[j];
  35.       y[j] := y[j+1];
  36.       y[j+1] := sum
  37.    END
  38. END;
  39.